package com.jx.controller.api;

import com.jx.common.result.AjaxResult;
import com.jx.pojo.entity.content.Article;
import com.jx.pojo.model.content.ArticleDetail;
import com.jx.service.content.ArticleService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/article")
public class ArticleApiController {

    @Resource
    private ArticleService articleService;

    /**
     * 获取详情
     */
    @GetMapping("/getById")
    public AjaxResult getById(Integer id) {
        ArticleDetail articleDetail = articleService.getArticleById(id);
        return AjaxResult.success(articleDetail);
    }

    /**
     * 根据关键词获取文章列表
     */
    @GetMapping("/getArticleListByKeyword")
    public AjaxResult getArticleListByKeyword(String keyword) {
        List<Article> list =  articleService.getArticleListByKeyword(keyword);
        return AjaxResult.success(list);
    }

}
